package com.atguigu.gmall.cart;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.cart.CartInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@FeignClient(value = "service-cart", fallback = CartFeignDegradeClient.class)
public interface CartFeignClient {

    @PostMapping("/api/cart/addToCart/{skuId}/{skuNum}")
    Result<Void> addToCart(
            @PathVariable("skuId") Long skuId,
            @PathVariable("skuNum") Integer skuNum);

    @GetMapping("/api/cart/inner/get/cart/checked/{userId}")
    Result<List<CartInfo>> getCheckedCartList(
            @PathVariable("userId") String userId);

    /**
     * 刷新购物车数据：确保 Redis 缓存中的购物项的价格是 skuPrice
     * @return
     */
    @GetMapping("/api/cart/inner/get/cart/list/from/db/to/cache/{userId}")
    Result<Void> getCartListFromDBToCache(@PathVariable("userId") String userId);

    @GetMapping("/api/cart/inner/clear/checked/cart/{userId}")
    Result<Void> clearCheckedCartItem(@PathVariable("userId") String userId);
}
